package com.xian.d4_polymorphic_test;

public class Computer {
    /**
     * 提供一个安装入口：行为
     */
    public void installUSB(USB u) {
        u.connect();

        //独有功能
        if (u instanceof Mouse) {
            Mouse m = (Mouse) u;
            m.click();
        } else if (u instanceof KeyBoard) {
            KeyBoard k = (KeyBoard) u;
            k.KeyDown();
        }


        u.unconnect();

    }
}
